<template>
  <div class="app-container">
    <el-card>
      <!--工具栏-->
      <div class="head-container">
         <eHeader :permission="permission"/>
         <crudOperation :permission="permission" />
       </div>
       <!--工具栏-->

      <!--表单组件-->

      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="jobName" label="职位名称"/>
        <el-table-column prop="city" label="工作地点"/>
        <el-table-column prop="companyName" label="所属公司" />
        <el-table-column prop="status" label="面试状态">
          <template slot-scope="scope">
            <el-button v-if ="scope.row.status === 0" type="primary" size="mini">未开始</el-button>
            <el-button v-else-if ="scope.row.status === 1"type="success" size="mini">待面试</el-button>
            <el-button v-else-if ="scope.row.status === 2"type="success" size="mini">通过啦</el-button>
            <el-button v-else ="scope.row.status === 3"type="warning" size="mini">拒绝啦</el-button>
          </template>
        </el-table-column>
        <el-table-column  label="操作" width="150px" align="center">
            <template slot-scope="scope">
              <!--<udOperation
                :data="scope.row"
                :permission="permission"
              />-->
              <el-button @click="showInterview(scope.row)" type="primary" size="mini">面试信息</el-button>
            </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </el-card>

    <el-dialog
      append-to-body
      :close-on-click-modal="false"
      :before-close="crud.cancelCU"
      :visible="visibleI"
      title="面试信息"
      width="500px"
    >
      <el-form
        ref="form"
        :model="form"
        size="small"
        label-width="80px"
      >

        <el-form-item label="地点" prop="address">
          {{form.address}}
        </el-form-item>

        <el-form-item label="时间" prop="time">
          {{form.time}}
        </el-form-item>

        <el-form-item label="备注" prop="remark">
          {{form.remark}}
        </el-form-item>


        <!--<el-form-item label="科目">
          <el-radio-group v-model="form.course" style="width: 178px">
            <el-radio :label="1">科目一</el-radio>
            <el-radio :label="2">科目二</el-radio>
            <el-radio :label="3">科目三</el-radio>
            <el-radio :label="4">科目四</el-radio>
          </el-radio-group>
        </el-form-item>-->

      </el-form>
      <div
        slot="footer"
        class="dialog-footer"
      >
        <el-button
          type="text"
          @click="visibleI = false"
        >
          取消
        </el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import checkPermission from '@/utils/permission'
import crudApplicant from '@/api/ceamApplicant'
import {getStudentList} from '../../../api/ceamStudent'
import eHeader from './header'
import CRUD, { presenter} from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
import udOperation from '@crud/UD.operation'

// crud交由presenter持有
const crud = CRUD({
  title: '我的面试',
  url: 'api/interview',
  sort: ['sort,asc', 'id,desc'],
  crudMethod: { ...crudApplicant }
})

export default {
  components: { eHeader, crudOperation, pagination, udOperation },
  mixins: [presenter(crud)],
  data() {
    return {
      delLoading: false,
      visibleI: false,
      form: {},
      studentList: [],
      permission: {
        add: ['admin', 'results:add'],
        edit: ['admin', 'results:edit'],
        del: ['admin', 'hrJob:del']
      }
    }
  },
  created() {
    this.$nextTick(() => {
      //this.init()
    })
  },
  methods: {
    checkPermission,
    showInterview(data) {
      this.form = data;
      this.visibleI = true;
    }
  }
}
</script>

<style scoped>

</style>
